﻿using Anke.SHManage.BLL;
using Anke.SHManage.MSSQLDAL;
using Anke.SHManage.Utility;
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Anke.SHManage.Web.Reports
{

    public partial class LS_FSCYCWebForm : System.Web.UI.Page
    {
        private string reportName;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
                InitPage();
            }
            else
            {
                reportName = Convert.ToString(ViewState["reportName"]);
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindReportDataSource();
        }
        private void InitPage()
        {
            reportName = Request.QueryString["ReportName"];
            ViewState["reportName"] = reportName;
            this.starttime.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");
            this.endtime.Text = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd 00:00:00");
            BindReportDataSource();
        }
        protected void BindReportDataSource()
        {
            DateTime dateStart = Convert.ToDateTime(this.starttime.Text);
            DateTime dateEnd = Convert.ToDateTime(this.endtime.Text);
            string start1 = dateStart.ToString();
            string centerID = Convert.ToString(this.Center.Text);
            string stationID = Convert.ToString(this.Station.Text);
            string workID = Convert.ToString(this.workID.Text);
            //string txtCenterAuditResult = Convert.ToString(this.txtCenterAuditResult.Text);
            this.ReportViewer1.LocalReport.DataSources.Clear();
            //  this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/LS_GRBLSHYPX.rdlc");
            this.ReportViewer1.LocalReport.ReportPath = Server.MapPath(@"~/Reports/LS_FSCYC.rdlc");
            LSDAL dal = new LSDAL();
            DataTable dt = dal.Get_LS_FSCYC(dateStart, dateEnd, centerID, stationID, workID);
            this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSetLS_FSCYC", dt));
            this.ReportViewer1.LocalReport.Refresh();
        }

    }
}